﻿<common:LayoutAwarePage
    x:Name="pageRoot"
    x:Class="Weather3.GroupDetailPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:Weather3"
    xmlns:data="using:Weather3.Data"
    xmlns:common="using:Weather3.Common"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">
    <Page.BottomAppBar>
        <AppBar x:Name="GlobalAppBar" Padding="10,0,10,0" Background="{StaticResource ComboBoxHighlightFillBrush}"  Margin="0,531,0,0">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="50*"/>
                        <ColumnDefinition Width="50*"/>
                    </Grid.ColumnDefinitions>
                    <StackPanel x:Name="LeftCommands" Orientation="Horizontal" Grid.Column="0" HorizontalAlignment="Left">
                        <Button x:Name="Back" Tag="Refresh" Style="{StaticResource RefreshAppBarButtonStyle}" HorizontalAlignment="Left" Margin="0"/>
                    </StackPanel>
                    <StackPanel x:Name="RightCommands" Orientation="Horizontal" Grid.Column="1" HorizontalAlignment="Right">
                        <Button x:Name="btnAdd"  Tag="Add" Style="{StaticResource SearchAppBarButtonStyle}" Click="btnAdd_Click" Height="88" />
                        <Button x:Name="btnCity" Tag="City" Click="btnCity_Click_1">
                        <Button.Style>
                            <Style TargetType="Button" BasedOn="{StaticResource AppBarButtonStyle}">
                                <Setter Property="AutomationProperties.AutomationId" Value="FavoriteAppBarButton"/>
                                <Setter Property="AutomationProperties.Name" Value="City"/>
                                <Setter Property="Content" Value=""/>
                            </Style>
                        </Button.Style>
                    </Button>
                        <Button Style="{StaticResource HelpAppBarButtonStyle}"/>

                    </StackPanel>
                </Grid>
            </AppBar>




    </Page.BottomAppBar>
    <UserControl.Resources>

        <!-- Collection of items displayed by this page -->
        <CollectionViewSource
            x:Name="itemsViewSource"
            Source="{Binding Items}"
            d:Source="{Binding ItemGroups[0].Items, Source={d:DesignInstance Type=data:SampleDataSource, IsDesignTimeCreatable=True}}"/>
    </UserControl.Resources>

    <!--
        This grid acts as a root panel for the page that defines two rows:
        * Row 0 contains the back button and page title
        * Row 1 contains the rest of the page layout
    -->
    <Grid x:Name="loadroot" Background="{StaticResource ComboBoxHighlightFillBrush}">

        <Grid.RowDefinitions>
            <RowDefinition Height="140"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>


        <!-- Back button and page title -->
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <Button x:Name="backButton" Click="GoBack" IsEnabled="false" Style="{StaticResource BackButtonStyle}"/>
            <TextBlock x:Name="pageTitle" Text="天气" Style="{StaticResource PageHeaderTextStyle}" Grid.Column="1"/>
        </Grid>

        <!-- Horizontal scrolling grid used in most view states -->
        <FlipView x:Name="flipView" Grid.Row="1" Margin="0,0,0,0">
            <FlipViewItem TabIndex="0">
                <local:Day1Weather x:Name="day0Weather" Day="0" Margin="0,0,0,0" />
            </FlipViewItem>
            <FlipViewItem>
                <local:Day1Weather x:Name="day1Weather" Day="1" />
            </FlipViewItem>
            <FlipViewItem x:Name="flipview">
                <local:Day1Weather x:Name="day2Weather" Day="2"/>
            </FlipViewItem>
            <FlipViewItem>
                <local:Day1Weather x:Name="day3Weather" Day="3"/>
            </FlipViewItem>
            <FlipViewItem>
                <!--<local:Day1Weather x:Name="day4Weather" Day="4"/>-->
            </FlipViewItem>

          
        </FlipView>

        <!-- Vertical scrolling list only used when snapped -->
        <ScrollViewer
            x:Name="snappedScrollViewer"
            AutomationProperties.AutomationId="SnappedDetailsScrollViewer"
            Grid.Row="1"
            Visibility="Collapsed"
            Style="{StaticResource VerticalScrollViewerStyle}">

            <StackPanel>
                <TextBlock Text="{Binding Subtitle}" Margin="20,0,18,20" Style="{StaticResource TitleTextStyle}" MaxHeight="60"/>
                <Image Source="{Binding Image}" Margin="20,0,18,0" MaxHeight="160" Stretch="UniformToFill"/>
                <TextBlock Margin="20,20,18,30" Text="{Binding Description}" Style="{StaticResource BodyTextStyle}"/>
                <ListView
                    AutomationProperties.AutomationId="ItemListView"
                    AutomationProperties.Name="Items In Group"
                    Margin="10,0,0,60"
                    ItemsSource="{Binding Source={StaticResource itemsViewSource}}"
                    ItemTemplate="{StaticResource Standard80ItemTemplate}"
                    SelectionMode="None"
                    IsItemClickEnabled="True"
                    />
            </StackPanel>
        </ScrollViewer>
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition/>
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>
            <StackPanel Grid.Column="1" Orientation="Horizontal"/>
            <StackPanel Orientation="Horizontal"/>
        </Grid>
        <VisualStateManager.VisualStateGroups>

            <!-- Visual states reflect the application's view state -->
            <VisualStateGroup>
                <VisualState x:Name="FullScreenLandscape"/>
                <VisualState x:Name="Filled"/>

                <!-- The entire page respects the narrower 100-pixel margin convention for portrait -->
                <VisualState x:Name="FullScreenPortrait">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" Storyboard.TargetProperty="Style">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PortraitBackButtonStyle}"/>
                        </ObjectAnimationUsingKeyFrames>

                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="gridLayoutPanel" Storyboard.TargetProperty="Margin">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="100,0,90,0"/>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>

                <!--
                    The back button and title have different styles when snapped, and the list representation is substituted
                    for the grid displayed in all other view states
                -->
                <VisualState x:Name="Snapped">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" Storyboard.TargetProperty="Style">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SnappedBackButtonStyle}"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="pageTitle" Storyboard.TargetProperty="Style">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SnappedPageHeaderTextStyle}"/>
                        </ObjectAnimationUsingKeyFrames>

                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="gridScrollViewer" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="snappedScrollViewer" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
    </Grid>
</common:LayoutAwarePage>
